package com.haizhi.crm.sys.shiro;

import com.haizhi.crm.common.util.PasswordEncrypt;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.CredentialsMatcher;

/**
 * Created by yangyijun on 18/7/2.
 */
public class UserCredentialsMatcher implements CredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;
        return PasswordEncrypt.matchPassword(new String(usernamePasswordToken.getPassword()), (String) info.getCredentials());
    }
}
